<template>
	<view>
	    <template v-if="showBigImg">
	    	<view class="bigImg" @tap='hideBigImg()'>
	    		<image :src="showImg" style="height: 490rpx;width: 490rpx;" mode=""></image>
	    	</view>
	    </template>
	    <view class="jui_flex jui_bg_fff recharge_tab">
	    	<view class="jui_flex1 jui_text_center jui_pad_2432" v-for="(item, index) in tabList" :key="index">
	    		<text class="jui_fs32 jui_fc_333 recharge_tab_text jui_pad_8" :class="{'active': tabIndex == index}"
	    			@tap="toggle(index)">{{item.value}}</text>
	    	</view>
	    </view>
		<view class="content jui_bg_fff">
			<view class="row">
				<view class="nominal jui_fc_333 jui_fs30">
					手机号
				</view>
				<view class="input">
					<input placeholder="请输入手机号" type="number" v-model="info.phone" style="width: 95%;" />
				</view>
			</view>
			<view class="row">
				<view class="nominal jui_fs30">
					数量
				</view>
				<view class="input">
					<input placeholder="请输入互转数量" type="number" v-model="info.num" style="width: 95%;" />
				</view>
			</view>
			<view class="row">
				<view class="jui_flex jui_flex_justify_between jui_flex_items_center bor" style="">
					<view class="" style="height: 64rpx; display: flex; align-items: center;">
						提现方式
					</view>
					<view class="jui_flex jui_flex_justify_between jui_flex_items_center" style="width: 180rpx; position: absolute; right:34rpx;">
						<xfl-select
							style="border: none;flex: 1;padding-right: 0"
							class="item-input flex-sub"
							:list="list"
							:clearable="false"
							:showItemNum="5"
							:isCanInput="false"
							:focusShowList="true"
							:placeholder="'placeholder'"
							:initValue="'请选择'"
							@change="change"
							:selectHideType="'hideAll'"
						></xfl-select>
					</view>
				</view>
			</view>
		
		</view>
		<!-- <view style="padding: 30rpx 20rpx;color:#666; background-color: #fff; border-bottom: solid 1px #f6f6f6;">可用CNY钱包余额：{{cnywallet || 0}}</view> -->
		<view style="padding: 30rpx 20rpx;color:#666; background-color: #fff;">可用BLTZ钱包余额：{{digitalwallet || 0}}</view>
		<view class="save">
			<view class="btn" @tap="submit()">提交</view>
		</view>
		<!-- 输入支付密码 -->
		<payPassword v-if="flag" @doSubmit="doSubmit" @hide="hide"></payPassword>
		<!-- 输入支付密码end -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tabList: [{
						value: '互转',
						type: 0
					},
					{
						value: '互转记录',
						type: 1
					},
				],
				tabIndex: 0,
				money1: '',
				info: {},
				flag: false,
				password: [],
				list: [
					{
						type: 'wallet',
						value: 'BLTZ钱包'
					},
				],
				current:0,
				cnywallet: uni.getStorageSync('cnywallet'), //人民币
				digitalwallet: uni.getStorageSync('digitalwallet') //数字货币
			};
		},
		onNavigationBarButtonTap(e) {
			uni.navigateTo({
				url: 'huzhuanLog'
			})
		},
		onLoad(e) {
			
		},
		methods: {
			toggle(index) {
				this.tabIndex = index;
				if(this.tabIndex==1){
					//提现记录
					uni.navigateTo({
						url: 'huzhuanLog'
					});
				}
			},
			// 选择充值金额
			change(e) {
				this.current = e.index;
				this.info.type = e.orignItem.type;
			},
			submit() {
				if (!this.info.phone) {
					return this.$msg("请输入手机号");
				}
				if (!this.info.num) {
					return this.$msg("请输入互转数量");
				}
				if(this.info.type == "" || this.info.type == null || this.info.type == undefined){
					return this.$msg("请选择提现方式")
				}
				this.flag = true;
			},
			doSubmit(data) {
				let userId = uni.getStorageSync('uid');
				let _token = uni.getStorageSync('token');
				let lockcnywallet = uni.getStorageSync('lockcnywallet');
				let lockdigitalwallet = uni.getStorageSync('lockdigitalwallet');
				this.password = data;
				this.info.pwd2 = this.password.toString();
				if(!lockdigitalwallet){
					this.$api.checkPayPwd({paypass:this.info.pwd2}).then(res => {
						if(res.ok){
							this.$msg(res.msg);
							let params = {
								 userId:userId,
								 _token:_token,
								 phone:this.info.phone,
								 transfer:this.info.phone,
								 paymoney:this.info.num,
								 paytype: this.info.type
							}
							this.$api.huzhuan2(params).then(res => {
								if (res.ok) {
									this.$msg(res.msg);
									setTimeout(() => {
										uni.navigateTo({
											url:`/pages/user/wallet/huzhuanLog`
										})
									}, 1500)
									
								}else{
									this.$msg(res.msg);
									this.hide()
								}
							});
						}else{
							this.$msg(res.msg)
							this.hide()
						}
					})
				}else{
					this.$msg("提现钱包已被冻结，禁止提现！")
				}
			},
			hide(data) {
				this.password = data;
				this.flag = false;
			}
		},
	};
</script>
<style lang="scss" scoped>
	.save {
		view {
			display: flex;
		}
		width: 100%;
		height: 120upx;
		display: flex;
		justify-content: center;
		align-items: center;
		margin-top: 60rpx;
		.btn {
			box-shadow: 0upx 5upx 10upx rgba(0, 0, 0, 0.4);
			width: 90%;
			height: 80upx;
			border-radius: 80upx;
			background-color: $zhuse;
			color: #fff;
			justify-content: center;
			align-items: center;
			.icon {
				height: 80upx;
				color: #fff;
				font-size: 30upx;
				justify-content: center;
				align-items: center;
			}
			font-size: 30upx;
		}
	}

	.content {
		display: flex;
		flex-wrap: wrap;
		view {
			display: flex;
		}
		.row {
			width: 94%;
			margin: 0 3%;
			border-bottom: solid 1upx #f6f6f6;
			.nominal {
				width: 30%;
				height: 90upx;
				font-size: 28upx;
				align-items: center;
				color: #333;
				font-family: "MI"
			}
			.input {
				width: 70%;
				padding: 20upx 0;
				align-items: center;
				font-size: 28upx;

				&.switch {
					justify-content: flex-end;
				}
				.textarea {
					margin: 20upx 0;
					min-height: 120upx;
				}
			}
			.del {
				width: 100%;
				height: 100upx;
				justify-content: center;
				align-items: center;
				font-size: 36upx;
				// color: $theme-color;
				background-color: #d9f3e1;
				border-bottom: solid 1upx #eee;
			}
		}
	}
	.recharge_tab {
		position: sticky;
		top: 0;
		left: 0;
		z-index: 9;
		.recharge_tab_text {
			position: relative;
		}
		.recharge_tab_text::after {
			content: '';
			width: 40%;
			height: 3px;
			background-color: #fff;
			position: absolute;
			bottom: 0;
			left: 30%;
			z-index: 1;
		}
		.recharge_tab_text.active::after {
			content: '';
			width: 40%;
			height: 3px;
			background-color: $zhuse;
			border-radius: 2px;
			position: absolute;
			bottom: 0;
			left: 30%;
			z-index: 1;
		}
	}
</style>
